package day07;

import java.util.Arrays;
import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {
        System.out.println("请输入评委人数：");
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        double[] d = enterData(a);
        outDate(addData(d),meanDate(d,a));
    }
    public static double[] enterData(int a){
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[a];
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第"+(i+1)+"个评委的分数");
      scores[i] = scan.nextInt();
        }
        return scores;
    }
    public static double addData(double[] scores){
        Arrays.sort(scores);
        int sum = 0;
        for (int i = 1; i < scores.length-1; i++) {
            sum+=scores[i];
        }
        return sum;
    }
    public static double meanDate(double[] scores,int a){
        Arrays.sort(scores);
        int sum = 0;
        for (int i = 1; i < scores.length-1; i++) {
            sum+=scores[i];
        }
        return sum/(a-2);
    }
    public static void outDate(double addData,double meanDate){
        System.out.println("总分是"+addData);
        System.out.println("平均分是"+meanDate);
    }
}
